#import "OmRegisterVCDatePickerView.h"
@interface OmRegisterVCDatePickerView ()
@property (nonatomic, strong) UIView *titleView;
@property (nonatomic, strong) UIButton *completeButton;
@end
@implementation OmRegisterVCDatePickerView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self configSelf];
        [self allocateComponents];
        [self layoutComponents];
    }
    return self;
}
- (void)configSelf {
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(WINDOW_WIDTH));
        make.height.equalTo(@(RPX(200)));
    }];
    self.fp_cornerRadius(RPX(6)).fp_backgroundColor(HexadecimalColor(@"#FFFFFF")).fp_clipsToBounds(YES);
}
- (void)allocateComponents {
    self.titleView = [[UIView alloc] init].fp_backgroundColor(HexadecimalColor(@"#F07896"));
    [self addSubview:self.titleView];
    self.completeButton = [[UIButton alloc] init].fp_addTargetActionForControlEvents(self, @selector(onCompleteButtonTap), UIControlEventTouchUpInside);
    [self.completeButton.titleLabel setFont:RPXFont(16)];
    [self.completeButton setTitle:ASLocalizedString(@"完成") forState:UIControlStateNormal];
    [self.titleView addSubview:self.completeButton];
    self.datePicker = [[UIDatePicker alloc] init];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    [self.datePicker setDate:[NSDate date] animated:YES];
    [self.datePicker setMaximumDate:[NSDate date]];
    [self addSubview:self.datePicker];
}
- (void)layoutComponents {
    [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.height.equalTo(@(RPX(30)));
    }];
    [self.completeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.titleView);
        make.right.equalTo(self.titleView).offset(RPX(-30));
    }];
    [self.datePicker mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleView.mas_bottom);
        make.left.right.bottom.equalTo(self);
    }];
}
- (void)onCompleteButtonTap {
    self.hidden = YES;
}
@end
